package cn.kogee.feignclient;

import cn.kogee.domian.User;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

@Component//添加注解交给spring管理
public class UserFeignClientFallbackFactory implements FallbackFactory<UserFeignClient> {
    @Override
    public UserFeignClient create(Throwable throwable) {
        return new UserFeignClient() {
            @Override
            public User getById(Long id) {
                return new User(-1L,"触发熔断机制","该服务不可使用");
            }
        };
    }
}
